package com.lwei.tallybook.client.cron;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.lwei.tallybook.client.config.SpringSupport;
import com.lwei.tallybook.service.service.AccountBookBillService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 默认的调度任务
 * @author sks.lwei
 */
@Log4j2
public class DefaultCronJob {

    /**
     * 运行定时任务主方法
     */
    public void run(){
        creatBill();
    }

    /**
     * 生成日常账单
     */
    public void creatBill(){
        AccountBookBillService billService = SpringSupport.getBean(AccountBookBillService.class);
        log.info("定时任务启动--生成账单");
        billService.creatAccountBookBill(new Date());
        log.info(DateUtil.now() + "账单生成完毕！");
    }


}
